<script>
import QuickLayout from '@/components/EmpsLayout/index.vue'
import { getBusinessEnumList } from '@/api/business/business'
import { formCV } from '@/api/form'

export default {
  name: 'Form',
  components: { QuickLayout },
  data() {
    return {
      dataListUrl: '/maku-generator/gen_dynamic_form/page',
      deleteUrl: '/maku-generator/gen_dynamic_form',
      businessEnum: []
    }
  },
  created() {
    this.getBusinessEnum()
  },
  methods: {
    getBusinessEnum() {
      getBusinessEnumList().then(resp => {
        const { data } = resp
        this.businessEnum = data
      })
    },
    handleEdit(id) {
      this.$router.push({ path: `/form-design?id=${id}` })
    },
    handlerCV(row) {
      formCV(row.id).then(() => {
        this.$message.success('复制成功')
        this.$refs.quickLayout.query()
      })
    }
  }
}
</script>

<template>
  <quick-layout
    ref="quickLayout"
    :is-operate-btn="true"
    :is-operate="true"
    :data-list-url="dataListUrl"
    :delete-url="deleteUrl"
    size="small"
    @edit="handleEdit"
  >
    <template v-slot:query="{query,reset}">
      <el-form-item label="表单类型">
        <el-select v-model="query.businessType" @change="reset()">
          <el-option label="全部" value="" />
          <el-option v-for="item in businessEnum" :key="item.type" :label="item.desc" :value="item.type" />
        </el-select>
      </el-form-item>
      <el-form-item label="模糊查询">
        <el-input v-model="query.keyword" style="width: 270px" placeholder="请输入关键词..." />
      </el-form-item>
    </template>
    <template>
      <el-table-column type="selection" header-align="center" align="center" width="50" />
      <el-table-column prop="name" label="表单名称" align="left" />
      <el-table-column prop="code" label="表单编码" align="left" />
      <el-table-column prop="type" label="表单类型" header-align="center" align="center" />
    </template>

    <template #operateBtn="{row}">
      <el-button type="text" size="small" @click="handlerCV(row)">复制</el-button>
    </template>
  </quick-layout>
</template>

<style scoped lang="scss">

</style>

